const mongoose = require('mongoose')
const md5 = require('../utils/md5')

const userSchema = new mongoose.Schema({
    username: {
        type: String, require: true
    }, email: {
        type: String, require: true
    }, password: {
        type: String, require: true, // 密码加密后存储
        set: value => md5(value), // 返回结果剔除密码
        select: false
    }, phone: {
        type: String, require: true
    }, image: {
        type: String, default: null
    }, createAt: {
        type: Date, require: true, default: Date.now()
    }, updateAt: {
        type: Date, require: true, default: Date.now()
    }
})


module.exports = userSchema

